#include<stdio.h>
int a[10000][10000];
int sp,ed,flag,tm,tn,k=0;
int next[4][2]={ {0,1},{1,0},{0,-1},{-1,0} };
void dfs(int x,int y,int step)
{
	int tx,ty,count=4;
	if(flag==2)
		return;
	
	if(a[x][y]==sp&&flag==0)
	{
		flag=1;
		sp=step+1;
		k++;
		tm-=2;
		tn-=2;
		if(tm<=0&&tn<=0)
		{
			flag=2;
			return;
		}
		switch(k%4)
		{
			case 0 : dfs(x+1,y+tn,step);break;
			case 1 : dfs(x+tm,y-1,step);break;
			case 2 : dfs(x-1,y-tn,step);break;
			case 3 : dfs(x-tm,y+1,step);break;
		}
		return;
	}
	else if(a[x][y]!=0)
	{
		k++;
		return;
	}
	else flag=0;
	while(flag==0&&count--)
		switch(k%4)
			{
				case 0: a[x][y]=step+1,dfs(x,y+1,step+1);break;
				case 1: a[x][y]=step+1,dfs(x+1,y,step+1);break;
				case 2: a[x][y]=step+1,dfs(x,y-1,step+1);break;
				case 3: a[x][y]=step+1,dfs(x-1,y,step+1);break;
			}
	flag=2;
	return;
}
int main()
{
	int m,n,i,j,k;
	scanf("%d%d",&m,&n);getchar();
	tm=m;tn=n;sp=1;
	for(i=0;i<=m+1;i+=m+1)
		for(j=0;j<=n+1;j++)
			a[i][j]=-1;
	for(j=0;j<=n+1;j+=n+1)
		for(i=0;i<=m+1;i++)
			a[i][j]=-1;
	/*for(i=0;i<=m+1;i++)
	{
		for(j=0;j<=n+1;j++)
		{
			printf("%d",a[i][j]);
			if(j!=n)
				printf(" ");
		}
		printf("\n");
	}
	a[1][1]=1;*/
	dfs(1,1,0);
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			printf("%d ",a[i][j]);
			/*if(j!=n)
				printf(" ");*/
		}
		printf("\n");
	}
	return 0;
}
